﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using SectionSignAndFilled.StairsRoomSection.DataDefine;

namespace SectionSignAndFilled.StairsRoomSection
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	internal class Cmdtest : IExternalCommand
	{
		Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			this.m_doc = commandData.Application.ActiveUIDocument.Document;
			ElementOwnerViewFilter elementOwnerViewFilter = new ElementOwnerViewFilter(this.m_doc.ActiveView.Id);
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_doc);
			filteredElementCollector.WherePasses(elementOwnerViewFilter);
			View activeView = this.m_doc.ActiveView;
			SectionViewData sectionViewData = new SectionViewData(activeView);
			sectionViewData.InitViewData();
			Outline outline = new Outline(sectionViewData.MinPt, sectionViewData.MaxPt);
			BoundingBoxIntersectsFilter input = new BoundingBoxIntersectsFilter(outline);
			FilteredElementCollectorLinkDocument filteredElementCollectorLinkDocument = new FilteredElementCollectorLinkDocument(this.m_doc);
			filteredElementCollectorLinkDocument.AddViewLimit(input);
			ElementClassFilter item = new ElementClassFilter(typeof(Dimension));
			ElementClassFilter item2 = new ElementClassFilter(typeof(Level));
			ElementClassFilter item3 = new ElementClassFilter(typeof(Grid));
			LogicalOrFilter filter = new LogicalOrFilter(new List<ElementFilter>
			{
				item2,
				item,
				item3
			});
			filteredElementCollectorLinkDocument.WherePass(filter).ToBeans();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private Document m_doc;
	}
}
